package com.axonactive.yolo.webservice;

import java.io.IOException;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import com.axonactive.yolo.webservice.utils.Utils;

@Path("/account")
public class LoginSignUp {

	/**
	 * @param
	 * KEY: loginParam
	 * VALUE: {"email":"example@axonactive.vn","password":"password_encrypted"}
	 * @return
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/login")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String login(MultivaluedMap<String, String> param)
			throws IOException, InterruptedException {
		return Utils.call("login/" + param.getFirst("loginParam"));
	}	

	/**
	 * @param
	 * KEY: signupParam
	 * VALUE: {"email":"example@axonactive.vn","password":"password_encrypted"}
	 * @return
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/signup")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String signup(MultivaluedMap<String, String> param)
			throws IOException, InterruptedException {
		return Utils.call("signup/" + param.getFirst("signupParam"));
	}	

}
